﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Xml;
using System.IO;

namespace JacketEmblem.Crane
{
    public class CraneBrowser
    {
        List<Window> openWindows = new List<Window>();
        Window focusedWindow;

        public CraneBrowser()
        {
            focusedWindow = new Window();
            openWindows.Add(focusedWindow);
        }

        public void LoadString(string html)
        {
            openWindows[0].LoadString(new StringReader(html));
        }

        public void Navigate(Uri location)
        {
            HttpWebRequest request = WebRequest.Create(location) as HttpWebRequest;
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            if (response.StatusCode == HttpStatusCode.OK)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                openWindows[0].LoadStream(reader);
            }
        }

        public Window FocusedWindow
        {
            get { return focusedWindow; }
            set { focusedWindow = value; }
        }
    }
}
